#pragma once

#include "icache/panel.h"
#include "resource.h"

class CacheSettingsDlg : public CDialog
{
	DECLARE_DYNAMIC(CacheSettingsDlg)

public:
	struct modal { };
	struct modaless { };
public:
	CacheSettingsDlg(modal, icache::panel & p, CWnd * pParent = 0);
	CacheSettingsDlg(modaless, icache::panel & p, CWnd * pParent = 0);
	virtual ~CacheSettingsDlg();

	enum { IDD = IDD_CACHE_SETTINGS };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()
private:
	void UpdateControls(icache::panel::data const & d);
	///copies current cache parameters in dialog controls
	void RetrieveCacheSettings();
	///sets values of dialog controls as current cache parameters
	void SetCacheSettings();
	template <class T> void GetMegabytes(int nID, T & i);
	void Changed(bool f);
private:
	icache::panel & _panel;
	bool _changed; ///< true if user chaneged values of one or more controls but don't confirmed changes yet
public:
	virtual BOOL OnInitDialog();
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnBnClickedPurgeMemCache();
	afx_msg void OnBnClickedPurgeDiscCache();
	afx_msg void OnBnClickedDiscCacheEraseOnExit();
	afx_msg void OnEditFocused();
	afx_msg void OnBnClickedApply();
	afx_msg void OnBnClickedOk();
	afx_msg void OnBnClickedChangeRootPath();
};
